home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr05 / shwdib.zip / SHOWDIB.H < prev    next >
C/C++ Source or Header  |  1993-07-26  |  9KB  |  241 lines

  1. /****************************************************************************
  2.  *                                        *
  3.  *  FILE    : SHOWDIB.H                            *
  4.  *                                        *
  5.  *  DESCRIPTION : Header/include file for ShowDIB example.            *
  6.  *                                        *
  7.  ****************************************************************************/
  8.  
  9. /* Macro to restrict a given value to an upper or lower boundary value */
  10. #define BOUND(x,min,max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
  11.  
  12. /* Macro to swap two values */
  13. #define SWAP(x,y)   ((x)^=(y)^=(x)^=(y))
  14.  
  15. /* Macro to find the minimum of two values */
  16. #define MIN(x,y) (((x) <= (y)) : x ? y)
  17.  
  18. /* Macros to display/remove hourglass cursor for lengthy operations */
  19. #define StartWait() hcurSave = SetCursor(LoadCursor(NULL,IDC_WAIT))
  20. #define EndWait()   SetCursor(hcurSave)
  21.  
  22. #define MINBAND     50     /* Minimum band size used by the program */
  23. #define BANDINCREMENT    20     /* Decrement for band size while trying    */
  24.                    /* to determine optimum band size.    */
  25.  
  26. /* Bit values for the DIB attributes flag (fFileOptions). Also used as control
  27.  * IDs for the radiobuttons for DIB bitcount in the File/Open dialog
  28.  */
  29. #define F_1BPP        DLGOPEN_1BPP
  30. #define F_4BPP        DLGOPEN_4BPP
  31. #define F_8BPP        DLGOPEN_8BPP
  32. #define F_24BPP     DLGOPEN_24BPP
  33.  
  34. /* Bit values for the DIB attributes flag (fFileOptions), also used as control
  35.  * IDs for the radiobuttons for DIB compression type in the File/Open dialog
  36.  */
  37. #define F_RLE4        DLGOPEN_RLE4
  38. #define F_RLE8        DLGOPEN_RLE8
  39. #define F_RGB        DLGOPEN_RGB
  40.  
  41. /* flags for _lseek */
  42. #define  SEEK_CUR 1
  43. #define  SEEK_END 2
  44. #define  SEEK_SET 0
  45.  
  46. /* struct to be passed in for the SETDIBSCALING printer escape */
  47. typedef struct {
  48.     short ScaleMode;
  49.     short dx, dy;
  50. } DIBPARAMS;
  51.  
  52. /* Menu IDs */
  53.  
  54. #define    IDM_UPDATECOL    1000
  55. #define    IDM_ANIMATE0    1001
  56. #define    IDM_ANIMATE5    5
  57. #define    IDM_ANIMATE20    20
  58. #define    IDM_ANIMATE50    50
  59. #define    IDM_ANIMATE100    100
  60. #define    IDM_ANIMATE200    200
  61. #define IDM_ANIMATE201    32000
  62.  
  63. #define IDM_OPEN    1002
  64. #define IDM_EXIT    1003
  65. #define IDM_ABOUT    1004
  66. #define    IDM_DIBSCREEN    1005
  67. #define    IDM_NOUGLY    1006
  68. #define    IDM_STEALCOL    1009
  69. #define    IDM_PRINT    1010
  70. #define IDM_COPY    1012
  71. #define IDM_MEMORYDIB    1014
  72. #define IDM_SAVE    1015
  73. #define IDM_TRANSPARENT 1016
  74.  
  75. #define IDM_PASTEDIB    1020
  76. #define IDM_PASTEDDB    1021
  77. #define IDM_PASTEPAL    1022
  78.  
  79. #define IDI_APP         2000
  80.  
  81. #define ABOUTBOX        100
  82.  
  83. extern HWND hWndApp;               /* The handle to the app. window     */
  84.  
  85. #define MAXREAD  32768               /* Number of bytes to be read during */
  86.                        /* each read operation.            */
  87.  
  88. /* Header signatutes for various resources */
  89. #define BFT_ICON   0x4349   /* 'IC' */
  90. #define BFT_BITMAP 0x4d42   /* 'BM' */
  91. #define BFT_CURSOR 0x5450   /* 'PT' */
  92.  
  93. /* macro to determine if resource is a DIB */
  94. #define ISDIB(bft) ((bft) == BFT_BITMAP)
  95.  
  96. /* Macro to align given value to the closest DWORD (unsigned long ) */
  97. #define ALIGNULONG(i)    ((i+3)/4*4)
  98.  
  99. /* Macro to determine to round off the given value to the closest byte */
  100. #define WIDTHBYTES(i)    ((i+31)/32*4)
  101.  
  102. #define PALVERSION      0x300
  103. #define MAXPALETTE    256      /* max. # supported palette entries */
  104.  
  105. /********** THE FOLLOWING ARE USED IN DLGOPEN.C  ************************/
  106.  
  107. /* IDs for controls in the DlgOpen dialog */
  108. #define DLGOPEN_EDIT        101
  109. #define DLGOPEN_FILE_LISTBOX    102
  110. #define DLGOPEN_DIR_LISTBOX    103
  111. #define DLGOPEN_PATH        104
  112. #define DLGOPEN_TEXT            105
  113. #define DLGOPEN_FOLDOUT         106
  114. #define DLGOPEN_BIG             107
  115. #define DLGOPEN_SMALL           108
  116.  
  117. #define DLGOPEN_OPTION          0xF000
  118. #define DLGOPEN_1BPP        0x0001
  119. #define DLGOPEN_4BPP        0x0002
  120. #define DLGOPEN_8BPP        0x0004
  121. #define DLGOPEN_24BPP        0x0008
  122. #define DLGOPEN_RLE4        0x0010
  123. #define DLGOPEN_RLE8        0x0020
  124. #define DLGOPEN_RGB        0x0040
  125.  
  126. #define DLGOPEN_OPTION8         0x0080
  127.  
  128. /*  flags:
  129.  *     The LOWORD is the standard FileOpen() flags (OF_*)
  130.  *     the HIWORD can be any of the following:
  131.  */
  132. #define OF_MUSTEXIST    0x00010000  /* file must exist if the user hits Ok    */
  133. #define OF_NOSHOWSPEC    0x00020000  /* DO NOT Show search spec in the edit box*/
  134. #define OF_SHOWSPEC    0x00000000  /* Show the search spec in the edit box   */
  135. #define OF_SAVE     0x00040000  /* Ok button will say "Save"          */
  136. #define OF_OPEN     0x00080000  /* Ok button will say "Open"          */
  137. #define OF_NOOPTIONS    0x00100000  /* Disable the options fold out          */
  138.  
  139. /* Attributes for DlgDirLst() */
  140. #define ATTRFILELIST    0x0000          /* include files only         */
  141. #define ATTRDIRLIST    0xC010          /* directories and drives ONLY */
  142. #define CBEXTMAX    6          /* Number of bytes in "\*.txt" */
  143.  
  144.  
  145. #define IDF(id)     ((id) & ~DLGOPEN_OPTION)  /* extracts flag from control ID */
  146. #define FID(f)        ((f)  |  DLGOPEN_OPTION)  /* extracts control ID from flag */
  147.  
  148. /***************** GLOBAL VARIABLES *************************/
  149.  
  150. extern char          achFileName[128]; /* File pathname               */
  151. extern DWORD          dwOffset;     /* Current position if DIB file pointer    */
  152. extern RECT          rcClip;        /* Current clip rectangle.               */
  153. extern BOOL          fPalColors;   /* TRUE if the current DIB's color table   */
  154.                     /* contains palette indexes not rgb values */
  155. extern BOOL          bDIBToDevice; /* Use SetDIBitsToDevice() to BLT data.    */
  156. extern BOOL          bLegitDraw;   /* We have a valid bitmap to draw           */
  157. extern WORD          wTransparent; /* Mode of DC                   */
  158. extern char          szAppName[];  /* App. name                   */
  159. extern HPALETTE       hpalCurrent;  /* Handle to current palette           */
  160. extern HANDLE          hdibCurrent;  /* Handle to current memory DIB           */
  161. extern HBITMAP          hbmCurrent;   /* Handle to current memory BITMAP           */
  162. extern HANDLE          hbiCurrent;   /* Handle to current bitmap info struct    */
  163. extern DWORD          dwStyle;        /* Style bits of the App. window           */
  164.  
  165. /***************** FUNCTION DECLARATIONS *******************/
  166.  
  167. DWORD PASCAL lread(int fh, VOID FAR *pv, DWORD ul);
  168. DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul);
  169.  
  170. /***********************************************************/
  171. /* Declarations of functions used in showdib.c module       */
  172. /***********************************************************/
  173.  
  174. long    FAR PASCAL WndProc  (HWND, UINT, WPARAM, LPARAM) ;
  175. BOOL           MenuCommand (HWND hWnd, WORD wParam);
  176. int           InitDIB (HWND);
  177. void           FreeDib (void);
  178.  
  179. /***********************************************************/
  180. /* Declarations of functions used in dib.c module       */
  181. /***********************************************************/
  182.  
  183. HANDLE        OpenDIB (LPSTR szFile);
  184. BOOL        WriteDIB (LPSTR szFile,HANDLE hdib);
  185. WORD        PaletteSize (VOID FAR * pv);
  186. WORD        DibNumColors (VOID FAR * pv);
  187. HPALETTE    CreateDibPalette (HANDLE hdib);
  188. HPALETTE    CreateBIPalette (LPBITMAPINFOHEADER lpbi);
  189. HANDLE        DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal);
  190. HANDLE        BitmapFromDib (HANDLE hdib, HPALETTE hpal);
  191. BOOL        DibBlt (HDC hdc, int x0, int y0, int dx, int dy, HANDLE hdib, int x1, int y1, LONG rop);
  192. BOOL        StretchDibBlt (HDC hdc, int x0, int y0, int dx, int dy, HANDLE hdib, int x1, int y1, int dx1, int dy1, LONG rop);
  193. BOOL        DibInfo (HANDLE hdib,LPBITMAPINFOHEADER lpbi);
  194. HANDLE        ReadDibBitmapInfo (int fh);
  195. BOOL        DrawBitmap (HDC hdc, int x, int y, HBITMAP hbm, DWORD rop);
  196.  
  197. /***********************************************************/
  198. /* Declarations of functions used in drawdib. c module       */
  199. /***********************************************************/
  200.  
  201. void           PrintDIB (HWND hWnd, HDC hDC, int x, int y, int dx, int dy);
  202. void           AppPaint (HWND hWnd, HDC hDC, int x, int y);
  203. int           ErrMsg (PSTR sz,...);
  204. BOOL           fDialog (int id, HWND hwnd, FARPROC fpfn);
  205. void           BandDIB (HWND hWnd, HDC hDC, int x, int y);
  206. BOOL    FAR PASCAL AppAbout (HWND, unsigned, WORD, LONG) ;
  207. HANDLE           CopyHandle (HANDLE h);
  208. void           SizeWindow (HWND hWnd);
  209. void           GetRealClientRect (HWND hwnd, PRECT lprc);
  210. void           SetScrollRanges (HWND hwnd);
  211. void           DrawSelect (HDC hdc, BOOL fDraw);
  212. void        PASCAL NormalizeRect (RECT *prc);
  213. void           TrackMouse (HWND hwnd, POINT pt);
  214. HBITMAP        CopyBitmap (HBITMAP hbm);
  215. HPALETTE       CopyPalette (HPALETTE hpal);
  216. HBITMAP        CropBitmap (HBITMAP hbm, PRECT prc);
  217. HANDLE           RenderFormat (int cf);
  218. HANDLE           RealizeDibFormat (DWORD biStyle, WORD biBits);
  219.  
  220. /***********************************************************/
  221. /* Declarations of functions used in the print.c module    */
  222. /***********************************************************/
  223.  
  224. BOOL    PASCAL InitPrinting (HDC hDC, HWND hWnd, HANDLE hInst, LPSTR msg);
  225. void    PASCAL TermPrinting (HDC hDC);
  226. HDC    PASCAL GetPrinterDC (void);
  227.  
  228. /***********************************************************/
  229. /* Declarations of functions used in the dlgopen.c module  */
  230. /***********************************************************/
  231.  
  232. int FAR PASCAL DlgfnOpen();
  233. int FAR PASCAL DlgOpenFile (
  234.     HWND        hwndParent,
  235.     char        *szTitle,
  236.     DWORD        flags,
  237.     char        *szExtIn,
  238.         char            *szFileNameIn,
  239.         WORD *          pfOpt
  240. );
  241.